<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%> 
<%@taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Chinac</title>
    <c:set var="ctx" value="<%=request.getContextPath()%>"></c:set>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="stylesheet" type="text/css" href="${ctx}/static/js/bootstrap/css/bootstrap.min.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="${ctx}/static/js/bootstrap/css/bootstrap-theme.min.css" media="screen" />
    <link rel="stylesheet" href="${ctx}/static/css/style_font.css">
    <link rel="stylesheet" href="${ctx}/static/css/style.css">
    <link rel="stylesheet" href="${ctx}/static/css/skins/_all-skins.css">
    <link type="text/css" href="/static/js/layer/skin/layer.css" rel="stylesheet"/>

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body class="hold-transition login-page" style="background-image:url(${ctx}/static/img/ifor-park.jpg);">
<div class="login-box">

    <div class="login-box-body">
        <p class="login-box-msg">登录管理后台</p>
        <form id="loginForm" method="post"  data-validator-option="{timely:2, theme:'simple_right'}">
            <div class="form-group has-feedback">
                <input id="name_input" type="text" class="form-control" placeholder="用户名" name="user.loginName" value="${loginName}" data-rule="用户名: required; username">
                <span class="icon hy-account form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input id="pwd_input" type="password" class="form-control" placeholder="密码" name="user.password" value="${password}" data-rule="密码: required; password">
                <span class="icon hy-lock form-control-feedback"></span>
            </div>
            <%--<div class="form-group has-feedback clearfix">--%>
                <%--<div class="pull-left pos_rel">--%>
                    <%--<input type="password" class="form-control" style="width: 160px;" placeholder="验证码" name="identify_code" data-rule="验证码: required">--%>
                    <%--<span class="icon hy-freeacess form-control-feedback"></span>--%>
                <%--</div>--%>
                <%--<div class="pull-right" style="width: 145px;">--%>
                    <%--<img src="../img/captcha.jpg" class="code_pic">--%>
                <%--</div>--%>
            <%--</div>--%>
            <div class="row">
                <div class="col-xs-3" style="margin-top: 5px">
                    <%--<a href="findpassword.html" style="margin-right: 5px">忘记密码 </a>--%>
                </div>
                <span  id="loginError" style="color:red;text-algin:center"></span>
                <div class="col-xs-6">
                    <button id="submit_btn" type="submit"  class="btn btn-primary btn-block btn-flat">登录</button>
                </div>
               
            </div>
        </form>
        <%--<div class="login-logo">--%>
            <%--<a href="#"><img src="../img/logo_login_b.png" alt="中国电建"></a>--%>
        <%--</div>--%>
    </div>

</div>

<script src="${ctx}/static/js/jquery-2.2.1.js"></script>
<script src="${ctx}/static/js/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/static/js/nice-validator/jquery.validator.js"></script>
<script type="text/javascript" src="/static/js/nice-validator/local/zh-CN.js"></script>
<script type="text/javascript" src="/static/js/layer/layer.js"></script>

<script>
     $(window).resize(function(){
        $(".signin").css({
            position: "absolute",
            left: ($(window).width() - $(".myblock").outerWidth())/2,
            top: ($(window).height() - $(".myblock").outerHeight())/2
        });
    });
    $(function(){
        $(window).resize();
    });
    $('#loginForm').validator({
        fields:{
            "user.name":"required",
			"user.password":"required"
        },
        valid: function(form) {
            var me = this;
            //在提交表单之前，保持表单，防止重复提交
            me.holdSubmit();
            $.ajax({
                url: '/asset/login.action',
                data: $(form).serialize(),        
                type: "POST",
                success: function(result){
                    // 表单提交成功之后，释放保持,此处的提交页面并未跳转，需要在下面进行跳转
                    if(result.operaRes == "0"){
                    	  me.holdSubmit(false);
                          location.href="/asset/listAsset.action";
                    }else{
                    	 layer.open({
                            title: '登录错误',
                            type: 0,                        
                            offset: ['250px', '830px'],
                            content: '<div style="color:red">输入的用户名或密码错误！</div>',
                            btn: ['确定', '取消'],
                            yes: function(index, layero) {
                           	 layer.close(index);
                           	 location.href="/asset/toLogin.action";
                           	 } 	
                       }) 
                    }
                },
                error: function(){
                	layer.alert("操作失败");
                }
            });                   
        }
    });   
   
</script>

</body>
</html>